package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type QueryEdgeConditions struct {
	Continent string   `json:"continent"`
	Country   string   `json:"country,omitempty"`
	City      string   `json:"city,omitempty"`
	Total     int64    `json:"total"`
	UUIDList  []string `json:"uuid_list,omitempty"`
	IsOnline  bool     `json:"is_online"`
}
type QueryEdgeListGetRequest struct {
	core.NCloudRequest
	QueryEdgeConditions
}

func NewQueryEdgeListGetRequest(continent string, total int64) *QueryEdgeListGetRequest {
	return &QueryEdgeListGetRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/gateway/edge",
			Method: consts.MethodPost,
		},
		QueryEdgeConditions: QueryEdgeConditions{
			IsOnline:  false,
			Continent: continent,
			Total:     total,
		},
	}
}
func NewQueryEdgeListGetRequestWithParams(continent, country, city string,
	total int64, uuidList []string, isOnline bool) *QueryEdgeListGetRequest {
	return &QueryEdgeListGetRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/gateway/edge",
			Method: consts.MethodPost,
		},
		QueryEdgeConditions: QueryEdgeConditions{
			Continent: continent,
			Country:   country,
			City:      city,
			Total:     total,
			UUIDList:  uuidList,
			IsOnline:  isOnline,
		},
	}
}
func (r *QueryEdgeListGetRequest) SetContinent(continent string) {
	r.QueryEdgeConditions.Continent = continent
}
func (r *QueryEdgeListGetRequest) SetCountry(country string) {
	r.QueryEdgeConditions.Country = country
}
func (r *QueryEdgeListGetRequest) SetCity(city string) {
	r.QueryEdgeConditions.City = city
}
func (r *QueryEdgeListGetRequest) SetTotal(total int64) {
	r.QueryEdgeConditions.Total = total
}
func (r *QueryEdgeListGetRequest) SetUUIDList(uuidList []string) {
	r.QueryEdgeConditions.UUIDList = uuidList
}
func (r *QueryEdgeListGetRequest) SetIsOnline(isOnline bool) {
	r.QueryEdgeConditions.IsOnline = isOnline
}

type EdgeInfo struct {
	Continent string `json:"continent"`
	Country   string `json:"country"`
	City      string `json:"city"`
	UUID      string `json:"uuid"`
	IP        string `json:"ip"`
	IsOnline  bool   `json:"is_online"`
}
type EdgeListResult struct {
	List  []EdgeInfo `json:"list"`
	Total int64      `json:"total"`
}
type QueryEdgeListGetResponse struct {
	Code    int            `json:"code"`
	Msg     string         `json:"msg"`
	Data    EdgeListResult `json:"data"`
	TrackID string         `json:"track_id"`
}
